<template>
  <div class="village_detail">
    <app-header :back="true" titleContent="公告详情"></app-header>
    <div class="top-title">
      <div class="title">{{detail.title}}</div>
      <div class="desc">
        <span class="author">{{detail.author}}</span>&nbsp;
        <span class="amount">浏览量：{{detail.reading_amount}}</span>&nbsp;
        <span class="time">{{detail.created_at*1000 |dateFmt(('YYYY-MM-DD HH:mm:ss'))}}</span>
      </div>
    </div>
    <p v-html="detail.content" class="content"></p>
  </div>
</template>
<style lang="less">
.village_detail {
  line-height: normal;
  background-color: #fff;
  overflow: auto;
  height: 100%;
  background-color: #fff;
  p {
  margin: 8px !important;
}
  .content{
    padding: 0 2px;
    margin-top: 8px;
  }
  .top-title{
    margin:0px 10px 0px 10px;
    .title{
    padding: 10px 0;
    text-align: center;
    font-size: 18px;
    line-height: 20px;
    font-weight: 700;
    border-bottom: 1px solid #f1f1f1;
    }
    .desc{
      padding-top: 10px;
      color: #666;
      font-size: 12px;
    }
  }
}
</style>
<script>
  import AppHeader from '../header/header'
  import {getNoticeDetail} from '../../api/notice.js'

  export default {
    name: 'noticeDetail',
    data () {
      return {
        detail: {},
        imgsArr: []
      }
    },
    created () {
      // console.log(document.getElementsByClassName('content')[0].getElementsByTagName('img'))
      setTimeout(function () {
        var imgs = document.getElementsByClassName('content')[0].getElementsByTagName('img')
        var imgsArr = []
        // debugger
        for (var i = 0; i < imgs.length; i++) {
          imgsArr.push(imgs[i].src)
          imgs[i].onclick = function () {
            console.log(this.src)
          }
        }
        this.imgsArr = imgsArr
        console.log(this.imgsArr)
      }, 1000)
      this._getNoticeDEtail()
    },
    methods: {
      _getNoticeDEtail () {
        getNoticeDetail(this.$route.params.id).then(res => {
          this.detail = res.data
        })
      }
    },
    components: {
      AppHeader
    }
  }
</script>

